import { config } from '@vue/test-utils'
import { vi } from 'vitest'

// Mock window.localStorage
const localStorageMock = (() => {
  let store = {}
  return {
    getItem: (key) => store[key] || null,
    setItem: (key, value) => {
      store[key] = value.toString()
    },
    removeItem: (key) => {
      delete store[key]
    },
    clear: () => {
      store = {}
    }
  }
})()

Object.defineProperty(window, 'localStorage', {
  value: localStorageMock,
  writable: true
})

// Mock window.location
delete window.location
window.location = {
  assign: vi.fn(),
  reload: vi.fn(),
  replace: vi.fn()
}

// Global mocks
config.global.mocks = {
  $t: (msg) => msg
}